﻿Imports System.ComponentModel
Imports BusinessLayer
Imports Ocean.OceanFramework.MVVM
Imports Ocean.OceanFramework.CommonDialog
Imports BusinessEntityObjects
Imports System.Collections.ObjectModel
Imports Ocean.OceanFramework.WPF.Utility.Helpers

Public Class RecentActivityViewModel
    Inherits ContainerFormViewModelBase

#Region " Declarations "

    Private _cmdBlogNavigateCommand As ICommand
    Private _objRecentBlogActivity As New List(Of BlogPost)

#End Region

#Region " Properties "

    Public Overrides Function SaveExecute() As Integer
        Return 1
    End Function

    Public Overrides ReadOnly Property IsDirty() As Boolean
        Get
            Return False
        End Get
    End Property

    Public Property RecentBlogActivity() As List(Of BlogPost)
        Get
            Return _objRecentBlogActivity
        End Get

        Private Set(ByVal Value As List(Of BlogPost))
            _objRecentBlogActivity = Value
            OnPropertyChanged("RecentBlogActivity")
        End Set
    End Property

#End Region

#Region " Command Properties "

    Public ReadOnly Property BlogNavigateCommand() As ICommand
        Get

            If _cmdBlogNavigateCommand Is Nothing Then
                _cmdBlogNavigateCommand = New RelayCommand(AddressOf BlogNavigateExecute, AddressOf CanBlogNavigateExecute)
            End If

            Return _cmdBlogNavigateCommand
        End Get
    End Property

#End Region

#Region " Constructor "

    Public Sub New(ByVal objRecentBlogActivity As List(Of BlogPost))
        Me.RecentBlogActivity = objRecentBlogActivity
        MyBase.ViewModelFriendlyName = "Recent Blog Activity"
    End Sub

#End Region

#Region " Methods "

    Private Sub BlogNavigateExecute(ByVal param As Object)

        If CanBlogNavigateExecute(param) Then

            Try
                StartProcessWithFileName(param.ToString)

            Catch ex As Exception
                ViewModelUIService.ExceptionDialog(ex)
            End Try

        End If

    End Sub

    Private Function CanBlogNavigateExecute(ByVal param As Object) As Boolean
        Return param IsNot Nothing AndAlso Not String.IsNullOrEmpty(param.ToString)
    End Function

#End Region

End Class
